package com.example.mapstructdemo;


import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * 转换的时候设置默认值
 */

@Mapper
public interface StudentDefaultValueMapper {

    StudentDefaultValueMapper INSTANCE = Mappers.getMapper(StudentDefaultValueMapper.class);

    @Mapping(source = "student.gender.name", target = "gender")
    @Mapping(source = "student.birthday", target = "birthday", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(source = "course.courseName", target = "course")
    @Mapping(target = "name", source = "student.name", defaultValue = "张三")
    StudentCourseVO studentAndCourse2StudentVO(Student student, Course course);
}
